﻿#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif

#include <DObjectHeader.h>

#include <QApplication>
#include <QTimer>

#include "DDBController.h"
#include "DLogInfoMgr.h"
#include "DMainView.h"
#include "DMainViewController.h"
#include "DQueryParaMgr.h"
#include "DSqliteMgr.h"

int main(int argc, char* argv[])
{
    QApplication a(argc, argv);

    getLogInfoMgr()->initLogInfo("/log");
    qInfo() << "enter system";

    // controller
    D_REGISTER_OBJECT1(DDBController);
    D_REGISTER_OBJECT1(DMainViewController);

    // mgr
    D_REGISTER_OBJECT1(DSqliteMgr);
    D_REGISTER_OBJECT1(DQueryParaMgr);

    DObjectPtr<DSqliteMgr> sqliteMgr;
    sqliteMgr->initDB();
    // sqliteMgr->testDB();

    DObjectPtr<DDBController> dbController;
    dbController->loadDB();

    // mgr
    DMainView* w = new DMainView();
    w->show();

    QTimer::singleShot(500,
                       [w]
                       {
                           DObjectPtr<DMainViewController> mainViewController;
                           mainViewController->setMainWindow(w);
                           mainViewController->loadTreeWgt();

                           mainViewController->slotQuery();
                       });

    a.exec();

    delete w;

    g_objMgr.releaseObject();
}
